package com.dengqi.mymodule.activity.guide;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;

import com.dengqi.mymodule.BaseActivity;
import com.dengqi.mymodule.MainActivity;
import com.dengqi.mymodule.R;

import androidx.annotation.Nullable;

/**
 *
 * Created by dell on 2018/6/19
 */

public class SplashActivity extends BaseActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide_splash);

        /**
         * 隐藏状态栏
         */
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION//隐藏nav栏
                        | View.SYSTEM_UI_FLAG_FULLSCREEN//隐藏状态栏
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(SplashActivity.this, MainActivity.class));
                overridePendingTransition(0, 0);
                //添加finish的话会有好多bug
//                finish();
            }
        }, 1500);


    }

    /**
     * 重写onDestroy
     * 不让AppManager.finishCurrentActivity();
     * 否则跳转会异常
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) { //拦截/屏蔽返回键
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
